package com.njmaomao.gj.pyot.domain.wechat.wechatapi;

import com.njmaomao.gj.pyot.domain.wechat.WechatApiUrlConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "wechatpay")
public class WechatApiUrlConfigFactory {

    private WechatApiUrlConfig url;

    private WechatApiUrlConfig sandboxurl;

    public WechatApiUrlConfig getUrl() {
        return url;
    }

    public void setUrl(WechatApiUrlConfig url) {
        this.url = url;
    }

    public WechatApiUrlConfig getSandboxurl() {
        return sandboxurl;
    }

    public void setSandboxurl(WechatApiUrlConfig sandboxurl) {
        this.sandboxurl = sandboxurl;
    }

    public WechatApiUrlConfig get(boolean isSandbox) {

        if(isSandbox) {
            return sandboxurl;
        }

        return url;
    }

    public String getGetsandboxsignkey() {
        return get(false).getGetsandboxsignkey();
    }
}
